<?

/**
 * Representation of an error page element for a web application,
 * as represented in a <code>&lt;error-page&gt;</code> element in the
 * deployment descriptor.
 */

class ErrorPage {


    // ----------------------------------------------------- Instance Variables


    /**
     * The error (status) code for which this error page is active.
     */
    private $errorCode = 0;


    /**
     * The exception type for which this error page is active.
     */
    private $exceptionType = null;


    /**
     * The context-relative location to handle this error or exception.
     */
    private $location = null;



    public function __construct($code, $location, $exceptionType = null) {
        $this->errorCode = $code;
        $this->location = $location;
        $this->exceptionType = $exceptionType;
    }


    // ------------------------------------------------------------- Properties


    /**
     * Return the error code.
     */
    public function getErrorCode() {

        return ($this->errorCode);

    }


    /**
     * Set the error code.
     *
     * @param errorCode The new error code
     */
    public function setErrorCode($errorCode) {

        $this->errorCode = intval($errorCode);

    }


    /**
     * Return the exception type.
     */
    public function getExceptionType() {

        return ($this->exceptionType);

    }


    /**
     * Set the exception type.
     *
     * @param exceptionType The new exception type
     */
    public function setExceptionType($exceptionType) {

        $this->exceptionType = $exceptionType;

    }


    /**
     * Return the location.
     */
    public function getLocation() {

        return ($this->location);

    }


    /**
     * Set the location.
     *
     * @param location The new location
     */
    public function setLocation($location) {

        $this->location = urldecode($location);

    }


    // --------------------------------------------------------- Public Methods


    /**
     * Render a String representation of this object.
     */
    public function __toString() {

        $sb = "ErrorPage[";
        if ($this->exceptionType == null) {
            $sb .= "errorCode=";
            $sb .= $this->errorCode;
        } else {
            $sb .= "exceptionType=";
            $sb .= $this->exceptionType;
        }
        $sb .= ", location=";
        $sb .= $this->location;
        $sb .= "]";
        return ($sb);

    }


}
